package com.suibibk.springCloud.order.controller;

import com.suibibk.springCloud.order.openfeign.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    RestTemplate restTemplate;

    @Autowired
    StockService stockService;
    @RequestMapping("/add")
    public String add(HttpServletRequest request){
        //1、获取请求头
       // String str = request.getHeader("X-Request-red");
        //2、获取参数
      //  String red = request.getParameter("red");
        //String msg = restTemplate.getForObject("http://stock-service/stock/reduce", String.class);
        String msg = stockService.reduce();
        //String from = request.getHeader("from");
        return "新增订单成功"+msg;
    }
}
